package com.tmptSource.dto;

import com.tmpt.utils.StringUtils;

import java.io.Serializable;

/**
 * Created by wxy on 2017/9/12.
 */
public class PageDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String sortColumn;
    private String sortOrder;
    private int pageCurrent=0;
    private int pageSize=0;
    private int pageIndex=0;

    /**
     * action中调用预处理，设置默认值
     * 分页/排序查询条件
     * 默认主键desc
     */
    public void configDefaultValue(){
        if(StringUtils.isNull(getSortColumn())){
            setSortColumn("id");
            setSortOrder("desc");
        }
        setPageCurrent(getPageCurrent()-1);
    }

    public String getSortColumn() {
        return sortColumn;
    }

    public void setSortColumn(String sortColumn) {
        this.sortColumn = sortColumn;
    }

    public String getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }

    public int getPageCurrent() {
        return pageCurrent;
    }

    public void setPageCurrent(int pageCurrent) {
        this.pageCurrent = pageCurrent;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageIndex() {
        return pageIndex=pageCurrent*pageSize;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
}
